class Restart{
    constructor(){
        this.btn = document.createElement('button');
        this.start();
        this.addlistener();
    }

    start(){
        
        this.btn.textContent = '重新开始'
        this.btn.style.cssText = `
            width: 50vw;
            height: 15vw;
            border-style: none;
            border-radius: 5rem;
            font-family: '华文新魏';
            font-size: 1.5rem;
            color: #bbffaa;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            background-color: rgba(249,147,164,0.7)
        `
        game.canvas.after(this.btn);

    }
    addlistener(){
        let self = this
        this.btn.onclick = function(){
            self.btn.style.cssText = '';
            game.audio.setAttribute('src','music/煞笔.mp3')
            game.run()
        }
    }
}